<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <div id="app">
        <neu-button :name="username"></neu-button>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        // 全局组件
        Vue.component('neu-button',{
            template : `<div><button @click="add">你好 {{name}},按钮被点击了 {{num}} 次</button></div>`,
            data(){
                return {
                    num : 0
                }
            },
            methods:{
                add(){
                    this.num++;
                }
            },
            props : ['name']
        })

        let vm = new Vue({
            el: '#app',
            data: {
                username : 'TOM'
            },
            methods: {},
        });
    </script>
</body>
</html>